module ApplicationHelper

    def food_json json,food
        food_base_json json,food
        if @car.order_items.map(&:food_id).include? food.id
            json.quantity @car.order_items.where(food_id:food.id).first.quantity
        end 
    end 

    def order_json json,item
        food_base_json json,item.food
        json.quantity item.quantity
        json.price item.single_price
    end 

    def food_base_json  json,food
        json.name food.name
        json.id food.id
        json.description food.description
        json.oldPrice food.show_price
        json.price food.sell_price
        json.sellCount 229        
        json.is_discount_food food.is_discount_food
        if food.is_discount_food
            json.discount food.discount_food.discount
            json.limit_sell food.discount_food.limit_sell
        end 
        json.ratings []
        json.icon asset_url(food.attachment.url(:icon))
        json.image asset_url(food.attachment.url(:image))
    end    

    def group_json json,group
        json.name group.name
        json.description group.description
        json.oldPrice group.show_price
        json.price group.price
        json.sellCount 229
        json.ratings []
        json.icon asset_url(food.attachment.url(:icon))
        json.image asset_url(food.attachment.url(:image))   
    end  


    def get_admin_navbar(title)
        content_for :navbar do
            render :partial => "admin/navbar",:locals => {title:title}
        end
    end  

    def get_restaurant_navbar(title)
        content_for :navbar do
            render :partial => "restaurants/navbar",:locals => {title:title}
        end
    end    




      
end
